home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / faketo1a / faketool.bas next >
BASIC Source File  |  1999-09-06  |  2KB  |  67 lines

  1. Attribute VB_Name = "Module1"
  2. Global Const SW_SHOWNOACTIVATE = 4
  3. Global Const GW_CHILD = 5         ' Needed for edit portion of
  4. ' combo box
  5. Type POINTAPI       ' Stores location of cursor
  6.     X As Long
  7.     Y As Long
  8. End Type
  9.  
  10. Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
  11. Declare Function GetActiveWindow Lib "user32" () As Long
  12. Declare Function WindowFromPoint Lib "user32" (ByVal X As Long, ByVal Y As Long) As Long
  13. Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
  14. Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
  15.  
  16.  
  17.  
  18. Sub DisplayHelp(Help$)
  19.     Dim lpPoint As POINTAPI ' Cursor Point variable
  20.     Dim ret As Long     ' Return value of ShowWindow()
  21.     ' API function
  22.     Rem Display Help String
  23.     Rem
  24.     Rem This Function displays the Help$ if Help$ <> "".
  25.     Rem if Help$ = "" then the Help String is removed.
  26.     Rem
  27.     Rem FUNCTION REQUIREMENTS:
  28.     Rem     GetCursorPos()    Windows API function
  29.     Rem     frmHelp           Name of the Help form
  30.     Rem
  31.  
  32.     If Len(Help$) <> 0 Then  ' Double check help$
  33.  
  34.         ' Make sure help form is invisible:
  35.         FrmHelp.Hide
  36.  
  37.         ' Change caption of label:
  38.         FrmHelp.Label1.Caption = Help$
  39.  
  40.         ' Get the cursor position so you can calculate where
  41.         ' to place the help form:
  42.         Call GetCursorPos(lpPoint)
  43.  
  44.         ' Offset the form from the cursor by 18 and 2 pixels (values
  45.         ' chosen to simulate the look of Microsoft Word version 6.0)
  46.         FrmHelp.Top = (lpPoint.Y + 18) * Screen.TwipsPerPixelY
  47.         FrmHelp.Left = (lpPoint.X - 2) * Screen.TwipsPerPixelY
  48.  
  49.         ' Adjust width of form to label + 4  because 2 are needed
  50.         ' for each pixel of the border and 2 are needed to center
  51.         ' the label (the label is inset by 1 pixel on the form).
  52.         ' Also, adjust height of form to height of label + 2
  53.         ' because 2 ar needed for each pixel of the border:
  54.         FrmHelp.Width = FrmHelp.Label1.Width + (4 * Screen.TwipsPerPixelX)
  55.         FrmHelp.Height = FrmHelp.Label1.Height + 2 * Screen.TwipsPerPixelY
  56.  
  57.         ' Make sure form is on top:
  58.         FrmHelp.ZOrder
  59.  
  60.         ' Show form without the focus:
  61.         ret = ShowWindow(FrmHelp.hwnd, SW_SHOWNOACTIVATE)
  62.     Else
  63.         ' Hide the form:
  64.         FrmHelp.Hide
  65.     End If
  66. End Sub
  67.